<template>
    <div class="iframe-container">
        <iframe
            ref="frame"
            :src="param.url"
            :height="param.height"
            allowfullscreen="true"
            webkitallowfullscreen="true"
            mozallowfullscreen="true"
        ></iframe>
    </div>
</template>

<script>
// import { MessageData } from '@/postMessageNorm';
export default {
    name: 'BusinessContainer',
    props: {
        param: Object
    },
    data() {
        return {
            
        };
    },
    mounted() {
        // 业务中台那边需要在打开的时候给他们传个宽度
        const frame = this.$refs.frame;
        frame.onload = function() {
        //console.log("iframe就绪！");
            let contentBox = process.client ? document.querySelector('#mainContent') : {};
            //将工作区的宽度去掉padding后传递给iframe
            let width = contentBox.clientWidth;
            const data = {
                messageType: 'clientWidth',
                clientWidth: width,
            };
            frame.contentWindow.postMessage(data, '*');
        };
    }
};
</script>

<style scoped lang="scss">
.iframe-container {
    width: 100%;
    height: 100%;

    iframe {
        border: none;
        width: 100%;
        // height: 100%;
        background-color: white;
    }
}
</style>